# myapp/serializers.py
from rest_framework import serializers
from .models import Notification


class NotificationSerializer(serializers.ModelSerializer):
    category_display = serializers.CharField(source='get_category_display', read_only=True)
    actor = serializers.CharField(source='actor.username', read_only=True)
    recipient = serializers.CharField(source='recipient.username', read_only=True)
    target = serializers.CharField(source='target.__str__', read_only=True, allow_null=True)
    action_object = serializers.CharField(source='action_object.__str__', read_only=True, allow_null=True)

    class Meta:
        model = Notification
        fields = '__all__'
        depth = 2
